#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    void read_number(int *arry);    //录入数字，并将其存入数组
    int arry_odd_number(int *arry, int *odd_arry);    //从数组中挑出奇数，并排序
    int arry_even_number(int *arry, int *even_arry);    //从数组中挑出偶数并排序
    void display(int *arry,int n);    //打印数组
    int arry[10],odd_arry[10],even_arry[10];    //定义三个数组
    int odd,even;
    cout << "Please enter 10 numbers:" << endl;
    read_number(arry);
    cout<<"After sort:"<<endl;
    odd=arry_odd_number(arry, odd_arry);
    display(odd_arry,odd);
    cout<<"   ";
    even=arry_even_number(arry, even_arry);
    display(even_arry,even); 
    system("pause");
}


// 读取数组
void read_number(int *arry)
{
    for (int i = 0; i <= 9; i++)
    {
        cin >> arry[i];
    }
}


//奇数部分
int arry_odd_number(int *arry, int *odd_arry)
{
    int j=0;
    for (int i = 0; i <= 9; i++)
    {
        if (arry[i] % 2 != 0)
        {
            odd_arry[j] = arry[i];
            j++;
        }
    }
    sort(odd_arry,odd_arry+j);
    return j;
}


// 偶数提取，及排序
int arry_even_number(int *arry, int *even_arry)
{
    int j=0;
    for (int i = 0; i <= 9; i++)
    {
        if (arry[i] % 2 == 0)
        {
            even_arry[j] = arry[i];
            j++;
        }
    }
    sort(even_arry,even_arry+j);
    return j;
}


void display(int *arry,int n)
{
    for(int i=0;i<=n-1;i++)
    {
        cout<<arry[i]<<" ";
    }
}